package com.joven.shelltest.test;

import com.joven.shelltest.dto.PersonalAccumulationFundDto;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @Author wzj
 * @Date 2023-08-24 17:31
 **/
public class OtherTest8 {
    public static void main(String[] args) {
        List<PersonalAccumulationFundDto> dateList = new ArrayList<>();
        PersonalAccumulationFundDto p1 = new PersonalAccumulationFundDto();
        p1.setJzrq("20230716");
        p1.setName("joven");
        p1.setFse("1000");

        PersonalAccumulationFundDto p2 = new PersonalAccumulationFundDto();
        p2.setJzrq("20230616");
        p2.setName("joven");
        p2.setFse("1100");

        PersonalAccumulationFundDto p16 = new PersonalAccumulationFundDto();
        p16.setJzrq("20230616");
        p16.setName("joven");
        p16.setFse("1000");

        PersonalAccumulationFundDto p3 = new PersonalAccumulationFundDto();
        p3.setJzrq("20230516");
        p3.setName("joven");
        p3.setFse("1000");

        PersonalAccumulationFundDto p4 = new PersonalAccumulationFundDto();
        p4.setJzrq("20230416");
        p4.setName("joven");
        p4.setFse("1200");

        PersonalAccumulationFundDto p5 = new PersonalAccumulationFundDto();
        p5.setJzrq("20230316");
        p5.setName("joven");
        p5.setFse("1000");

        PersonalAccumulationFundDto p6 = new PersonalAccumulationFundDto();
        p6.setJzrq("20230216");
        p6.setName("joven");
        p6.setFse("1000");

        PersonalAccumulationFundDto p7 = new PersonalAccumulationFundDto();
        p7.setJzrq("20230116");
        p7.setName("joven");
        p7.setFse("1000");


        PersonalAccumulationFundDto p8 = new PersonalAccumulationFundDto();
        p8.setJzrq("20221216");
        p8.setName("joven");
        p8.setFse("1300");


        PersonalAccumulationFundDto p9 = new PersonalAccumulationFundDto();
        p9.setJzrq("20221116");
        p9.setName("joven");
        p9.setFse("1000");


        PersonalAccumulationFundDto p10 = new PersonalAccumulationFundDto();
        p10.setJzrq("20221016");
        p10.setName("joven");
        p10.setFse("1000");


        PersonalAccumulationFundDto p11 = new PersonalAccumulationFundDto();
        p11.setJzrq("20220916");
        p11.setName("joven");
        p11.setFse("1000");


        PersonalAccumulationFundDto p12 = new PersonalAccumulationFundDto();
        p12.setJzrq("20220816");
        p12.setName("joven");
        p12.setFse("1000");

        PersonalAccumulationFundDto p13 = new PersonalAccumulationFundDto();
        p13.setJzrq("20220716");
        p13.setName("joven");
        p13.setFse("1000");


        PersonalAccumulationFundDto p14 = new PersonalAccumulationFundDto();
        p14.setJzrq("20220616");
        p14.setName("joven");
        p14.setFse("1000");


        PersonalAccumulationFundDto p15 = new PersonalAccumulationFundDto();
        p15.setJzrq("20220516");
        p15.setName("joven");
        p15.setFse("1000");

        dateList.add(p1);
        dateList.add(p2);
        dateList.add(p3);
        dateList.add(p4);
        dateList.add(p5);
        dateList.add(p6);
        dateList.add(p7);
        dateList.add(p8);
        dateList.add(p9);
        dateList.add(p10);
        dateList.add(p11);
        dateList.add(p12);
        dateList.add(p13);
        dateList.add(p14);
        dateList.add(p15);
        dateList.add(p16);

        for (PersonalAccumulationFundDto data : dateList) {
            boolean flag = "20220816".equals(data.getJzrq());
            if (flag) {
                System.out.println("success");
            }
        }


        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.MONTH, -1);
        Date newDate = calendar.getTime();
        SimpleDateFormat monthFormat = new SimpleDateFormat("yyyyMMdd");
        System.out.println("减去一月后的日期: " + monthFormat.format(newDate));


        calendar.setTime(newDate);
        calendar.add(Calendar.YEAR, -1);
        Date newDate1 = calendar.getTime();
        System.out.println("减去一年后的日期: " + monthFormat.format(newDate1));

//        dateList.stream().filter(p -> {
//            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//            try {
//                Date date = format.parse(p.getJzrq());
//
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//            return false;
//        });
    }
}
